<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<link rel="STYLESHEET" href="lib.css" type='text/css' />
<link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" />
<link rel='start' href='../index.html' title='Python documentation Index' />
<link rel="first" href="lib.html" title='Python library Reference' />
<link rel='contents' href='contents.html' title="Contents" />
<link rel='index' href='genindex.html' title='Index' />
<link rel='last' href='about.html' title='About this document...' />
<link rel='help' href='about.html' title='About this document...' />
<link rel="next" href="imap4-example.html" />
<link rel="prev" href="module-imaplib.html" />
<link rel="parent" href="module-imaplib.html" />
<link rel="next" href="imap4-example.html" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name='aesop' content='information' />
<title>18.11.1 IMAP4 Objects </title>
</head>
<body>
<div class="navigation">
<div id='top-navigation-panel' xml:id='top-navigation-panel'>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td class='online-navigation'><a rel="prev" title="18.11 imaplib  "
  href="module-imaplib.html"><img src='../icons/previous.png'
  border='0' height='32'  alt='Previous Page' width='32' /></a></td>
<td class='online-navigation'><a rel="parent" title="18.11 imaplib  "
  href="module-imaplib.html"><img src='../icons/up.png'
  border='0' height='32'  alt='Up one Level' width='32' /></a></td>
<td class='online-navigation'><a rel="next" title="18.11.2 imap4 Example"
  href="imap4-example.html"><img src='../icons/next.png'
  border='0' height='32'  alt='Next Page' width='32' /></a></td>
<td align="center" width="100%">Python Library Reference</td>
<td class='online-navigation'><a rel="contents" title="Table of Contents"
  href="contents.html"><img src='../icons/contents.png'
  border='0' height='32'  alt='Contents' width='32' /></a></td>
<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
  border='0' height='32'  alt='Module Index' width='32' /></a></td>
<td class='online-navigation'><a rel="index" title="Index"
  href="genindex.html"><img src='../icons/index.png'
  border='0' height='32'  alt='Index' width='32' /></a></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="module-imaplib.html">18.11 imaplib  </a>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="module-imaplib.html">18.11 imaplib  </a>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="imap4-example.html">18.11.2 IMAP4 Example</a>
</div>
<hr /></div>
</div>
<!--End of Navigation Panel-->

<h2><a name="SECTION00201110000000000000000"></a><a name="imap4-objects"></a>
<br>
18.11.1 IMAP4 Objects 
</h2>

<p>
All IMAP4rev1 commands are represented by methods of the same name,
either upper-case or lower-case.

<p>
All arguments to commands are converted to strings, except for
"<tt class="samp">AUTHENTICATE</tt>", and the last argument to "<tt class="samp">APPEND</tt>" which is
passed as an IMAP4 literal.  If necessary (the string contains IMAP4
protocol-sensitive characters and isn't enclosed with either
parentheses or double quotes) each string is quoted. However, the
<var>password</var> argument to the "<tt class="samp">LOGIN</tt>" command is always quoted.
If you want to avoid having an argument string quoted
(eg: the <var>flags</var> argument to "<tt class="samp">STORE</tt>") then enclose the string in
parentheses (eg: <code>r'(\Deleted)'</code>).

<p>
Each command returns a tuple: <code>(<var>type</var>, [<var>data</var>,
...])</code> where <var>type</var> is usually <code>'OK'</code> or <code>'NO'</code>,
and <var>data</var> is either the text from the command response, or
mandated results from the command. Each <var>data</var>
is either a string, or a tuple. If a tuple, then the first part
is the header of the response, and the second part contains
the data (ie: 'literal' value).

<p>
The <var>message_set</var> options to commands below is a string specifying one
or more messages to be acted upon.  It may be a simple message number
(<code>'1'</code>), a range of message numbers (<code>'2:4'</code>), or a group of
non-contiguous ranges separated by commas (<code>'1:3,6:9'</code>).  A range
can contain an asterisk to indicate an infinite upper bound
(<code>'3:*'</code>).

<p>
An <tt class="class">IMAP4</tt> instance has the following methods:

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-4115' xml:id='l2h-4115' class="method">append</tt></b>(</nobr></td>
  <td><var>mailbox, flags, date_time, message</var>)</td></tr></table></dt>
<dd>
  Append <var>message</var> to named mailbox. 
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-4116' xml:id='l2h-4116' class="method">authenticate</tt></b>(</nobr></td>
  <td><var>mechanism, authobject</var>)</td></tr></table></dt>
<dd>
  Authenticate command -- requires response processing.

<p>
<var>mechanism</var> specifies which authentication mechanism is to be
  used - it should appear in the instance variable <code>capabilities</code>
  in the form <code>AUTH=mechanism</code>.

<p>
<var>authobject</var> must be a callable object:

<p>
<div class="verbatim"><pre>
data = authobject(response)
</pre></div>

<p>
It will be called to process server continuation responses.
  It should return <code>data</code> that will be encoded and sent to server.
  It should return <code>None</code> if the client abort response "<tt class="samp">*</tt>" should
  be sent instead.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-4117' xml:id='l2h-4117' class="method">check</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
  Checkpoint mailbox on server. 
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-4118' xml:id='l2h-4118' class="method">close</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
  Close currently selected mailbox. Deleted messages are removed from
  writable mailbox. This is the recommended command before
  "<tt class="samp">LOGOUT</tt>".
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-4119' xml:id='l2h-4119' class="method">copy</tt></b>(</nobr></td>
  <td><var>message_set, new_mailbox</var>)</td></tr></table></dt>
<dd>
  Copy <var>message_set</var> messages onto end of <var>new_mailbox</var>. 
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-4120' xml:id='l2h-4120' class="method">create</tt></b>(</nobr></td>
  <td><var>mailbox</var>)</td></tr></table></dt>
<dd>
  Create new mailbox named <var>mailbox</var>.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-4121' xml:id='l2h-4121' class="method">delete</tt></b>(</nobr></td>
  <td><var>mailbox</var>)</td></tr></table></dt>
<dd>
  Delete old mailbox named <var>mailbox</var>.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-4122' xml:id='l2h-4122' class="method">deleteacl</tt></b>(</nobr></td>
  <td><var>mailbox, who</var>)</td></tr></table></dt>
<dd>
  Delete the ACLs (remove any rights) set for who on mailbox.

<span class="versionnote">New in version 2.4.</span>

</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-4123' xml:id='l2h-4123' class="method">expunge</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
  Permanently remove deleted items from selected mailbox. Generates an
  "<tt class="samp">EXPUNGE</tt>" response for each deleted message. Returned data
  contains a list of "<tt class="samp">EXPUNGE</tt>" message numbers in order
  received.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-4124' xml:id='l2h-4124' class="method">fetch</tt></b>(</nobr></td>
  <td><var>message_set, message_parts</var>)</td></tr></table></dt>
<dd>
  Fetch (parts of) messages.  <var>message_parts</var> should be
  a string of message part names enclosed within parentheses,
  eg: "<tt class="samp">"(UID BODY[TEXT])"</tt>".  Returned data are tuples
  of message part envelope and data.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-4125' xml:id='l2h-4125' class="method">getacl</tt></b>(</nobr></td>
  <td><var>mailbox</var>)</td></tr></table></dt>
<dd>
  Get the "<tt class="samp">ACL</tt>"s for <var>mailbox</var>.
  The method is non-standard, but is supported by the "<tt class="samp">Cyrus</tt>" server.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-4126' xml:id='l2h-4126' class="method">getannotation</tt></b>(</nobr></td>
  <td><var>mailbox, entry, attribute</var>)</td></tr></table></dt>
<dd>
  Retrieve the specified "<tt class="samp">ANNOTATION</tt>"s for <var>mailbox</var>.
  The method is non-standard, but is supported by the "<tt class="samp">Cyrus</tt>" server.

<span class="versionnote">New in version 2.5.</span>

</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-4127' xml:id='l2h-4127' class="method">getquota</tt></b>(</nobr></td>
  <td><var>root</var>)</td></tr></table></dt>
<dd>
  Get the "<tt class="samp">quota</tt>" <var>root</var>'s resource usage and limits.
  This method is part of the IMAP4 QUOTA extension defined in rfc2087.

<span class="versionnote">New in version 2.3.</span>

</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-4128' xml:id='l2h-4128' class="method">getquotaroot</tt></b>(</nobr></td>
  <td><var>mailbox</var>)</td></tr></table></dt>
<dd>
  Get the list of "<tt class="samp">quota</tt>" "<tt class="samp">roots</tt>" for the named <var>mailbox</var>.
  This method is part of the IMAP4 QUOTA extension defined in rfc2087.

<span class="versionnote">New in version 2.3.</span>

</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-4129' xml:id='l2h-4129' class="method">list</tt></b>(</nobr></td>
  <td><var></var><big>[</big><var>directory</var><big>[</big><var>, pattern</var><big>]</big><var></var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
  List mailbox names in <var>directory</var> matching
  <var>pattern</var>.  <var>directory</var> defaults to the top-level mail
  folder, and <var>pattern</var> defaults to match anything.  Returned data
  contains a list of "<tt class="samp">LIST</tt>" responses.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-4130' xml:id='l2h-4130' class="method">login</tt></b>(</nobr></td>
  <td><var>user, password</var>)</td></tr></table></dt>
<dd>
  Identify the client using a plaintext password.
  The <var>password</var> will be quoted.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-4131' xml:id='l2h-4131' class="method">login_cram_md5</tt></b>(</nobr></td>
  <td><var>user, password</var>)</td></tr></table></dt>
<dd>
  Force use of "<tt class="samp">CRAM-MD5</tt>" authentication when identifying the
  client to protect the password.  Will only work if the server
  "<tt class="samp">CAPABILITY</tt>" response includes the phrase "<tt class="samp">AUTH=CRAM-MD5</tt>".

<span class="versionnote">New in version 2.3.</span>

</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-4132' xml:id='l2h-4132' class="method">logout</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
  Shutdown connection to server. Returns server "<tt class="samp">BYE</tt>" response.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-4133' xml:id='l2h-4133' class="method">lsub</tt></b>(</nobr></td>
  <td><var></var><big>[</big><var>directory</var><big>[</big><var>, pattern</var><big>]</big><var></var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
  List subscribed mailbox names in directory matching pattern.
  <var>directory</var> defaults to the top level directory and
  <var>pattern</var> defaults to match any mailbox.
  Returned data are tuples of message part envelope and data.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-4134' xml:id='l2h-4134' class="method">myrights</tt></b>(</nobr></td>
  <td><var>mailbox</var>)</td></tr></table></dt>
<dd>
  Show my ACLs for a mailbox (i.e. the rights that I have on mailbox).

<span class="versionnote">New in version 2.4.</span>

</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-4135' xml:id='l2h-4135' class="method">namespace</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
  Returns IMAP namespaces as defined in RFC2342.

<span class="versionnote">New in version 2.3.</span>

</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-4136' xml:id='l2h-4136' class="method">noop</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
  Send "<tt class="samp">NOOP</tt>" to server.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-4137' xml:id='l2h-4137' class="method">open</tt></b>(</nobr></td>
  <td><var>host, port</var>)</td></tr></table></dt>
<dd>
  Opens socket to <var>port</var> at <var>host</var>.
  The connection objects established by this method
  will be used in the <code>read</code>, <code>readline</code>, <code>send</code>, and
  <code>shutdown</code> methods.
  You may override this method.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-4138' xml:id='l2h-4138' class="method">partial</tt></b>(</nobr></td>
  <td><var>message_num, message_part, start, length</var>)</td></tr></table></dt>
<dd>
  Fetch truncated part of a message.
  Returned data is a tuple of message part envelope and data.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-4139' xml:id='l2h-4139' class="method">proxyauth</tt></b>(</nobr></td>
  <td><var>user</var>)</td></tr></table></dt>
<dd>
  Assume authentication as <var>user</var>.
  Allows an authorised administrator to proxy into any user's mailbox.

<span class="versionnote">New in version 2.3.</span>

</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-4140' xml:id='l2h-4140' class="method">read</tt></b>(</nobr></td>
  <td><var>size</var>)</td></tr></table></dt>
<dd>
  Reads <var>size</var> bytes from the remote server.
  You may override this method.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-4141' xml:id='l2h-4141' class="method">readline</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
  Reads one line from the remote server.
  You may override this method.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-4142' xml:id='l2h-4142' class="method">recent</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
  Prompt server for an update. Returned data is <code>None</code> if no new
  messages, else value of "<tt class="samp">RECENT</tt>" response.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-4143' xml:id='l2h-4143' class="method">rename</tt></b>(</nobr></td>
  <td><var>oldmailbox, newmailbox</var>)</td></tr></table></dt>
<dd>
  Rename mailbox named <var>oldmailbox</var> to <var>newmailbox</var>.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-4144' xml:id='l2h-4144' class="method">response</tt></b>(</nobr></td>
  <td><var>code</var>)</td></tr></table></dt>
<dd>
  Return data for response <var>code</var> if received, or
  <code>None</code>. Returns the given code, instead of the usual type.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-4145' xml:id='l2h-4145' class="method">search</tt></b>(</nobr></td>
  <td><var>charset, criterion</var><big>[</big><var>, ...</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
  Search mailbox for matching messages.  <var>charset</var> may be
  <code>None</code>, in which case no "<tt class="samp">CHARSET</tt>" will be specified in the
  request to the server.  The IMAP protocol requires that at least one
  criterion be specified; an exception will be raised when the server
  returns an error.

<p>
Example:

<p>
<div class="verbatim"><pre>
# M is a connected IMAP4 instance...
typ, msgnums = M.search(None, 'FROM', '"LDJ"')

# or:
typ, msgnums = M.search(None, '(FROM "LDJ")')
</pre></div>
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-4146' xml:id='l2h-4146' class="method">select</tt></b>(</nobr></td>
  <td><var></var><big>[</big><var>mailbox</var><big>[</big><var>, readonly</var><big>]</big><var></var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
  Select a mailbox. Returned data is the count of messages in
  <var>mailbox</var> ("<tt class="samp">EXISTS</tt>" response).  The default <var>mailbox</var>
  is <code>'INBOX'</code>.  If the <var>readonly</var> flag is set, modifications
  to the mailbox are not allowed.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-4147' xml:id='l2h-4147' class="method">send</tt></b>(</nobr></td>
  <td><var>data</var>)</td></tr></table></dt>
<dd>
  Sends <code>data</code> to the remote server.
  You may override this method.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-4148' xml:id='l2h-4148' class="method">setacl</tt></b>(</nobr></td>
  <td><var>mailbox, who, what</var>)</td></tr></table></dt>
<dd>
  Set an "<tt class="samp">ACL</tt>" for <var>mailbox</var>.
  The method is non-standard, but is supported by the "<tt class="samp">Cyrus</tt>" server.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-4149' xml:id='l2h-4149' class="method">setannotation</tt></b>(</nobr></td>
  <td><var>mailbox, entry, attribute</var><big>[</big><var>, ...</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
  Set "<tt class="samp">ANNOTATION</tt>"s for <var>mailbox</var>.
  The method is non-standard, but is supported by the "<tt class="samp">Cyrus</tt>" server.

<span class="versionnote">New in version 2.5.</span>

</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-4150' xml:id='l2h-4150' class="method">setquota</tt></b>(</nobr></td>
  <td><var>root, limits</var>)</td></tr></table></dt>
<dd>
  Set the "<tt class="samp">quota</tt>" <var>root</var>'s resource <var>limits</var>.
  This method is part of the IMAP4 QUOTA extension defined in rfc2087.

<span class="versionnote">New in version 2.3.</span>

</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-4151' xml:id='l2h-4151' class="method">shutdown</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
  Close connection established in <code>open</code>.
  You may override this method.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-4152' xml:id='l2h-4152' class="method">socket</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
  Returns socket instance used to connect to server.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-4153' xml:id='l2h-4153' class="method">sort</tt></b>(</nobr></td>
  <td><var>sort_criteria, charset, search_criterion</var><big>[</big><var>, ...</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
  The <code>sort</code> command is a variant of <code>search</code> with sorting
  semantics for the results.  Returned data contains a space separated
  list of matching message numbers.

<p>
Sort has two arguments before the <var>search_criterion</var>
  argument(s); a parenthesized list of <var>sort_criteria</var>, and the
  searching <var>charset</var>.  Note that unlike <code>search</code>, the
  searching <var>charset</var> argument is mandatory.  There is also a
  <code>uid sort</code> command which corresponds to <code>sort</code> the way
  that <code>uid search</code> corresponds to <code>search</code>.  The
  <code>sort</code> command first searches the mailbox for messages that
  match the given searching criteria using the charset argument for
  the interpretation of strings in the searching criteria.  It then
  returns the numbers of matching messages.

<p>
This is an "<tt class="samp">IMAP4rev1</tt>" extension command.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-4154' xml:id='l2h-4154' class="method">status</tt></b>(</nobr></td>
  <td><var>mailbox, names</var>)</td></tr></table></dt>
<dd>
  Request named status conditions for <var>mailbox</var>. 
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-4155' xml:id='l2h-4155' class="method">store</tt></b>(</nobr></td>
  <td><var>message_set, command, flag_list</var>)</td></tr></table></dt>
<dd>
  Alters flag dispositions for messages in mailbox.  <var>command</var> is
  specified by section 6.4.6 of <a class="rfc" id='rfcref-103099' xml:id='rfcref-103099'
href="http://www.faqs.org/rfcs/rfc2060.html">RFC 2060</a> as being one of "FLAGS", "+FLAGS",
  or "-FLAGS", optionally with a suffix of ".SILENT".

<p>
For example, to set the delete flag on all messages:

<p>
<div class="verbatim"><pre>
typ, data = M.search(None, 'ALL')
for num in data[0].split():
   M.store(num, '+FLAGS', '\\Deleted')
M.expunge()
</pre></div>
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-4156' xml:id='l2h-4156' class="method">subscribe</tt></b>(</nobr></td>
  <td><var>mailbox</var>)</td></tr></table></dt>
<dd>
  Subscribe to new mailbox.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-4157' xml:id='l2h-4157' class="method">thread</tt></b>(</nobr></td>
  <td><var>threading_algorithm, charset,
                           search_criterion</var><big>[</big><var>, ...</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
  The <code>thread</code> command is a variant of <code>search</code> with
  threading semantics for the results.  Returned data contains a space
  separated list of thread members.

<p>
Thread members consist of zero or more messages numbers, delimited
  by spaces, indicating successive parent and child.

<p>
Thread has two arguments before the <var>search_criterion</var>
  argument(s); a <var>threading_algorithm</var>, and the searching
  <var>charset</var>.  Note that unlike <code>search</code>, the searching
  <var>charset</var> argument is mandatory.  There is also a <code>uid
  thread</code> command which corresponds to <code>thread</code> the way that
  <code>uid search</code> corresponds to <code>search</code>.  The <code>thread</code>
  command first searches the mailbox for messages that match the given
  searching criteria using the charset argument for the interpretation
  of strings in the searching criteria. It then returns the matching
  messages threaded according to the specified threading algorithm.

<p>
This is an "<tt class="samp">IMAP4rev1</tt>" extension command. 
<span class="versionnote">New in version 2.4.</span>

</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-4158' xml:id='l2h-4158' class="method">uid</tt></b>(</nobr></td>
  <td><var>command, arg</var><big>[</big><var>, ...</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
  Execute command args with messages identified by UID, rather than
  message number.  Returns response appropriate to command.  At least
  one argument must be supplied; if none are provided, the server will
  return an error and an exception will be raised.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-4159' xml:id='l2h-4159' class="method">unsubscribe</tt></b>(</nobr></td>
  <td><var>mailbox</var>)</td></tr></table></dt>
<dd>
  Unsubscribe from old mailbox.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-4160' xml:id='l2h-4160' class="method">xatom</tt></b>(</nobr></td>
  <td><var>name</var><big>[</big><var>, arg</var><big>[</big><var>, ...</var><big>]</big><var></var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
  Allow simple extension commands notified by server in
  "<tt class="samp">CAPABILITY</tt>" response.
</dl>

<p>
Instances of <tt class="class">IMAP4_SSL</tt> have just one additional method:

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-4161' xml:id='l2h-4161' class="method">ssl</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
  Returns SSLObject instance used for the secure connection with the server.
</dl>

<p>
The following attributes are defined on instances of <tt class="class">IMAP4</tt>:

<p>
<dl><dt><b><tt id='l2h-4162' xml:id='l2h-4162' class="member">PROTOCOL_VERSION</tt></b></dt>
<dd>
The most recent supported protocol in the
"<tt class="samp">CAPABILITY</tt>" response from the server.
</dl>

<p>
<dl><dt><b><tt id='l2h-4163' xml:id='l2h-4163' class="member">debug</tt></b></dt>
<dd>
Integer value to control debugging output.  The initialize value is
taken from the module variable <code>Debug</code>.  Values greater than
three trace each command.
</dl>

<p>

<div class="navigation">
<div class='online-navigation'>
<p></p><hr />
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td class='online-navigation'><a rel="prev" title="18.11 imaplib  "
  href="module-imaplib.html"><img src='../icons/previous.png'
  border='0' height='32'  alt='Previous Page' width='32' /></a></td>
<td class='online-navigation'><a rel="parent" title="18.11 imaplib  "
  href="module-imaplib.html"><img src='../icons/up.png'
  border='0' height='32'  alt='Up one Level' width='32' /></a></td>
<td class='online-navigation'><a rel="next" title="18.11.2 imap4 Example"
  href="imap4-example.html"><img src='../icons/next.png'
  border='0' height='32'  alt='Next Page' width='32' /></a></td>
<td align="center" width="100%">Python Library Reference</td>
<td class='online-navigation'><a rel="contents" title="Table of Contents"
  href="contents.html"><img src='../icons/contents.png'
  border='0' height='32'  alt='Contents' width='32' /></a></td>
<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
  border='0' height='32'  alt='Module Index' width='32' /></a></td>
<td class='online-navigation'><a rel="index" title="Index"
  href="genindex.html"><img src='../icons/index.png'
  border='0' height='32'  alt='Index' width='32' /></a></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="module-imaplib.html">18.11 imaplib  </a>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="module-imaplib.html">18.11 imaplib  </a>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="imap4-example.html">18.11.2 IMAP4 Example</a>
</div>
</div>
<hr />
<span class="release-info">Release 2.5.1, documentation updated on 18th April, 2007.</span>
</div>
<!--End of Navigation Panel-->
<address>
See <i><a href="about.html">About this document...</a></i> for information on suggesting changes.
</address>
</body>
</html>
